Dear DXL experts!
/* runLim = 0 means no restriction for total runtime,
* i.e. no more timeouts will be reported. */
pragma runLim, 0
/*project to be displayed in list (with leading '/') */
string projectToView = "/M3AR"
/* first count all Folders in project */
Item itm
Project prj = project projectToView
int numberOfFolders = 0,
numberOfModules = 0
/* walkthrough on all elements of the project and counting all folders and formal modules */
for itm in prj do {
if (type(itm) == "Folder") {
numberOfFolders++
} else if (type(itm) == "Formal") {
numberOfModules++
}
}
/* allocate double of needed space for security reason */
string sourceModuleName[numberOfModules*2]
/* read all folders to string array, for further use in list box */
string modules[numberOfFolders]
int i=0
for itm in prj do {
if (type(itm) == "Folder") {
modules[i]=fullName itm
i++
}
}
DB moduleInputBox = create ("Choose module directory for modifying enum items", styleCentered)
DBE attributeColumn = field (moduleInputBox, "Name of Attribute Column:", "RadioType", 20)
DBE oldEnumColumn = field (moduleInputBox, "Current name of enum item :", "All", 20)
DBE newEnumColumn = field (moduleInputBox, "New name of enum item:", "M3AR Family", 20)
DBE sourceModuleList = multiList (moduleInputBox, "Choose module:",500, sizeof(modules), modules, sizeof(modules))
bool firstTime = true,
actionDel = false
int affectedItem = 0,
currChoice = 0,
allChoice = 0
/* callback function for sourceModuleList -------------------------------- */
void getSource(DBE sourceModuleList) {
/* i is the place of the selected item within the module list */
int position = get sourceModuleList
allChoice++
if (firstTime){
firstTime = false
sourceModuleName[currChoice]=modules[position]
currChoice++
print "(FIRST) sourceModuleName: " sourceModuleName[currChoice-1] " currChoice = " currChoice "\n"
} else{
for (j=0; j<currChoice; j++){
if (sourceModuleName[j]==modules[position]) {
print "(DEL-found) sourceModuleName: " sourceModuleName[j] " position = " position "\n"
actionDel = true
affectedItem = j
}
}
if (actionDel){
if (currChoice<=1){
sourceModuleName[0] = ""
} else {
for (j=0; j<currChoice-1; j++){
if (j >= affectedItem){
sourceModuleName[j] = sourceModuleName[j+1]
}
}
}
currChoice--
actionDel = false
print "(DEL-made) currChoice = " currChoice "\n"
} else{
sourceModuleName[currChoice]=modules[position]
currChoice++
print "(INS) sourceModuleName: " sourceModuleName[currChoice-1] " position = " position "\n"
}
}// else
print "EVERY LOOP, currChoice = " currChoice " allChoice = " allChoice "\n\n"
} // getSource
set(sourceModuleList, getSource)
/* ----------------------------------------------------------------------- */
void getSourceInput(DB fieldBox) {
string refAttribute = get attributeColumn
string refOldEnum = get oldEnumColumn
string refNewEnum = get newEnumColumn
/* error handling if choice is empty */
if (get sourceModuleList==null) {
errorBox("Choose module directory!")
return
}
/* link all modules in given folder */
int step
for (step=0; step<currChoice; step++){
modifyAllFromModule(folder(sourceModuleName[step]), refAttribute, refOldEnum, refNewEnum)
}
}//getSourceInput
ok(moduleInputBox, getSourceInput)
show moduleInputBox
vasgyuszi - Mon Mar 15 10:35:16 EDT 2010 |
Re: inconsistent behaviour of DXL script ?
Hey vasgyuszi,
pragma runLim, 0
string someArr[] = {"Mod1", "Mod2", "Mod3", "Mod4"}
DB moduleInputBox = create ("Choose module directory for modifying enum items", styleCentered)
DBE sourceModuleList = multiList (moduleInputBox, "Choose module:",500, 6,someArr, 4)
// feel free to use show and a callback with button like you did
block moduleInputBox
release moduleInputBox
hide moduleInputBox
int i
// iterate over highlighted items ...
for i in sourceModuleList do {
print "Doing it for module " someArr[i] "\n"
}
|
Re: inconsistent behaviour of DXL script ? Mathias Mamsch - Mon Mar 15 18:32:23 EDT 2010
Hey vasgyuszi,
pragma runLim, 0
string someArr[] = {"Mod1", "Mod2", "Mod3", "Mod4"}
DB moduleInputBox = create ("Choose module directory for modifying enum items", styleCentered)
DBE sourceModuleList = multiList (moduleInputBox, "Choose module:",500, 6,someArr, 4)
// feel free to use show and a callback with button like you did
block moduleInputBox
release moduleInputBox
hide moduleInputBox
int i
// iterate over highlighted items ...
for i in sourceModuleList do {
print "Doing it for module " someArr[i] "\n"
}
I thought at second look that my solution maybe unnecessary complicated ;) My goal was to have a continuous list of directories after not specified number of mouse clicks. It's allowed to the user to clicking any items any times and all that count is the currently highlighted items just before clicking on "OK" button. I needed that complicated list processing algorithm because without it my callback function will be called each time the user clicks on an item with the mouse. Regardless if the item will be deselected or selected, it will be added to my list of directories. It can be seen that is not the right way. So I have to distinguish between the two types of mouse-clicks (selecting/deselecting). The algorithm itself seems now to be correct BUT sometimes (sporadic, not predictable) a delete action will be recognizes as an insert action and I don't know why. I will take a look on your solution and refer on it. Best regards, vasgyuszi |
Re: inconsistent behaviour of DXL script ? vasgyuszi - Mon Mar 15 21:03:42 EDT 2010 Move your mouse over an item, press the left mouse button down (don't let it go yet) then move the mouse over another item and let go of the mouse button. It seems to happen randomly since it will happen every time, when you click on an items very fast and move your mouse in the short time while holding down the mousebutton to another item. Then highlight and selection will run out of sync. Regards, Mathias |
Re: inconsistent behaviour of DXL script ? |
Re: inconsistent behaviour of DXL script ? vasgyuszi - Mon Mar 15 21:03:42 EDT 2010 Best regards, vasgyuszi |
Re: inconsistent behaviour of DXL script ? SystemAdmin - Tue Mar 16 11:58:52 EDT 2010 Yes, your thoughts are right. |
Re: inconsistent behaviour of DXL script ? Mathias Mamsch - Tue Mar 16 09:26:59 EDT 2010 Now it works fine, THX! vasgyuszi |